/**
 * English Dry Capacity Unit Tests
 * Tests convert and toUnit for each Unit Type
 */

package cmsc495.mach2.test.unit.english;

import cmsc495.mach2.unit.english.EnglishDryCapacityUnit;
import junit.framework.TestCase;

/**
 * @author Michael Swann
 */
public class EnglishDryCapacityUnitValidation extends TestCase {

	// Amount of Error Allowed
	private static final double						DELTA					= 0.01;

	private static final double						PINTS_VALUE				= 64;
	private static final double						QUARTS_VALUE			= 32;
	private static final double						PECKS_VALUE				= 4;
	private static final double						BUSHELS_VALUE			= 1;
	private static final double						LITERS_VALUE			= 35.2390703995;

	private static final double						values[]				= { PINTS_VALUE, QUARTS_VALUE, PECKS_VALUE, BUSHELS_VALUE, LITERS_VALUE };
	private static final EnglishDryCapacityUnit[]	englishDryCapacityUnits	= EnglishDryCapacityUnit.values();

	public EnglishDryCapacityUnitValidation() {
	}

	@Override
	protected void setUp() throws Exception {
		super.setUp();
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishDryCapacityUnit#convert(double, mach2convert.englishunit.EnglishDryCapacityUnit)}
	 * .
	 */
	public final void testConvert() {
		for (int i = 0; i < englishDryCapacityUnits.length; i++) {
			for (int j = 0; j < englishDryCapacityUnits.length; j++) {
				double result = englishDryCapacityUnits[i].convert(values[j], englishDryCapacityUnits[j]);
				System.out.println("ASSERT: " + values[i] + " = " + result + " " + englishDryCapacityUnits[i] + ".convert(" + values[j] + ", " + englishDryCapacityUnits[j] + "))");
				assertEquals(values[i], result, DELTA);
			}
		}
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishDryCapacityUnit#toPints(double)}.
	 */
	public final void testToPints() {
		for (int i = 0; i < englishDryCapacityUnits.length; i++) {
			double result = englishDryCapacityUnits[i].toPints(values[i]);
			System.out.println("ASSERT: " + PINTS_VALUE + " = " + result + " " + englishDryCapacityUnits[i] + ".toPints(" + values[i] + ") ");
			assertEquals(PINTS_VALUE, result, DELTA);
		}
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishDryCapacityUnit#toQuarts(double)}.
	 */
	public final void testToQuarts() {
		for (int i = 0; i < englishDryCapacityUnits.length; i++) {
			double result = englishDryCapacityUnits[i].toQuarts(values[i]);
			System.out.println("ASSERT: " + QUARTS_VALUE + " = " + result + " " + englishDryCapacityUnits[i] + ".toQuarts(" + values[i] + ") ");
			assertEquals(QUARTS_VALUE, result, DELTA);
		}
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishDryCapacityUnit#toPecks(double)}.
	 */
	public final void testToPecks() {
		for (int i = 0; i < englishDryCapacityUnits.length; i++) {
			double result = englishDryCapacityUnits[i].toPecks(values[i]);
			System.out.println("ASSERT: " + PECKS_VALUE + " = " + result + " " + englishDryCapacityUnits[i] + ".toPecks(" + values[i] + ") ");
			assertEquals(PECKS_VALUE, result, DELTA);
		}
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishDryCapacityUnit#toBushels(double)}
	 * .
	 */
	public final void testToBushels() {
		for (int i = 0; i < englishDryCapacityUnits.length; i++) {
			double result = englishDryCapacityUnits[i].toBushels(values[i]);
			System.out.println("ASSERT: " + BUSHELS_VALUE + " = " + result + " " + englishDryCapacityUnits[i] + ".toBushels(" + values[i] + ") ");
			assertEquals(BUSHELS_VALUE, result, DELTA);
		}
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishDryCapacityUnit#toLiters(double)}.
	 */
	public final void testToLiters() {
		for (int i = 0; i < englishDryCapacityUnits.length; i++) {
			double result = englishDryCapacityUnits[i].toLiters(values[i]);
			System.out.println("ASSERT: " + LITERS_VALUE + " = " + result + " " + englishDryCapacityUnits[i] + ".toLiters(" + values[i] + ") ");
			assertEquals(LITERS_VALUE, result, DELTA);
		}
	}

}